package com.abel.cloud.gateway;

import com.abel.cloud.gateway.filter.UserGatewayFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * Author: Abel.lin
 * Date: 2021/5/11 10:24
 * Company: Abel Studio
 * Copyright: Copyright (c) 2017
 * Description:
 */
@EnableEurekaClient
@SpringBootApplication
public class GatewayApplication {
    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
    }

    @Bean
    public RouteLocator routeLocator(RouteLocatorBuilder builder) {
        return builder.routes().route(r ->
                r.path("/user/*")
                        .uri("lb://ABEL-PROVIDER")
                        .id("provider_route")
                        .filters(new UserGatewayFilter()))
                .build();
    }
}
